package editor;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JColorChooser;
import javax.swing.JDialog;
import javax.swing.JPanel;

public class DialogColoreSfondo extends JDialog implements ActionListener {
	private Editor editor;
	private JButton ok;
	private JButton annulla;
	private JColorChooser sfondo;
	
	public DialogColoreSfondo (Editor editor){
		this.editor = editor;
		JPanel pann = new JPanel();
		this.setContentPane(pann);
		ok = new JButton("Ok");
		ok.setPreferredSize(new Dimension(90,30));
		ok.addActionListener(this);
		
		annulla = new JButton("Annulla");
		annulla.setPreferredSize(new Dimension(90,30));
		annulla.addActionListener(this);
		
		sfondo = new JColorChooser();
		pann.add(sfondo);
		pann.add(ok);
		pann.add(annulla);
		this.setSize(new Dimension (450,420));
		this.setResizable(false);
		this.setTitle("Imposta sfondo livello");
		this.setVisible(true);
	}

	public void actionPerformed(ActionEvent e) {
		if (e.getSource() == ok){
			editor.setFileSfondo(null);
			editor.setSfondoEditor(sfondo.getColor());
			this.dispose();			
		}
		if (e.getSource() == annulla){
			this.dispose();
		}
		
	}

}
